Add an example to README for keymap binding
authorJustin Burkett <justin@burkett.cc>
Tue, 19 Apr 2022 02:26:35 +0000 (22:26 -0400)
committerJustin Burkett <justin@burkett.cc>
Tue, 19 Apr 2022 02:26:35 +0000 (22:26 -0400)
See #338

README.org

index 994931813d76f2f8bbc1852a7855edc1d0d4d6d0..9d9a4c4a57b1c17b8aeef18ce859cf5d2ad30e34 100644 (file)
      example,
 
      #+BEGIN_SRC emacs-lisp
-     (define-key some-map "f" '("foo" . command-foo))
-     (define-key some-map "b" '("bar-prefix" . (keymap)))
+       (define-key some-map "f" '("foo" . command-foo))
+       (define-key some-map "b" '("bar-prefix" . (keymap)))
+       (setq my-map (make-sparse-keymap))
+       (define-key some-map "b" (cons "bar-prefix" my-map))
      #+END_SRC
 
      binds =command-foo= to =f= in =some-map=, but also stores the string "foo"
      which which-key will extract to use to describe this command. The second
      example binds an empty keymap to =b= in =some-map= and uses "bar-prefix" to
-     describe it. These bindings are accepted by =define-key= natively (i.e.,
-     with or without which-key being loaded). Since many key-binding utilities
-     use =define-key= internally, this functionality should be available with
-     your favorite method of defining keys as well.
+     describe it. The last two lines replicate the functionality of the second
+     line, while assigning the new keymap to the symbol =my-map= (note the use
+     of =cons= to ensure that =my-map= is evaluated for =define-key=). These
+     bindings are accepted by =define-key= natively (i.e., with or without
+     which-key being loaded). Since many key-binding utilities use =define-key=
+     internally, this functionality should be available with your favorite
+     method of defining keys as well.
 
      The second method is to use =which-key-add-keymap-based-replacements=. The
      statement